package threading;

/**
 * @author krystal
 * @date 2022/11/22 21:46
 */
//演示多线程的基本创建方式
//继承Thread，重写run
class MyThread extends Thread{
    @Override
    public void run(){
        System.out.println("hello thread!");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

public class Demo1 {
    public static void main(String[] args) {
        MyThread t=new MyThread();
        t.start();

        while (true){
            System.out.println("hello main!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
